# Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.

# CMake lowest version requirement
cmake_minimum_required(VERSION 3.5.1)

# project information
project(YOLOV3_coco_detection_4_thread)

# Compile options
add_compile_options(-std=c++11)

# Specify target generation path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY  "./")
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall")

set(CPU_ARCH "aarch64")
set(INSTALL_DIR "/home/HwHiAiUser/Ascend/nnrt/latest")
set(THIRDPART_PATH "/usr/local")

add_definitions(-DENABLE_DVPP_INTERFACE)
list(APPEND COMMON_DEPEND_LIB acllite avcodec avformat avdevice avutil swresample avfilter swscale)
if (${CPU_ARCH} MATCHES "aarch64")
    if(EXISTS "$ENV{INSTALL_DIR}/driver/libmedia_mini.so")
        list(APPEND COMMON_DEPEND_LIB media_mini ascend_hal c_sec mmpa slog)
        add_definitions(-DENABLE_BOARD_CAMARE)
        message(STATUS "arch: arm")
    endif()
endif()


# Header path
include_directories(
    ./include/
    ${INSTALL_DIR}/runtime/include/
    ${THIRDPART_PATH}/include/
    ${THIRDPART_PATH}/include/opencv4
)


# add host lib path
link_directories(
    ${INSTALL_DIR}/runtime/lib64/stub
    ${THIRDPART_PATH}/lib/
    ${INSTALL_DIR}/driver
)

add_executable(main
        src/yolov3_clip_detector.cpp
        main.cpp)

target_link_libraries(main
        ascendcl acl_dvpp stdc++ ${COMMON_DEPEND_LIB} opencv_highgui opencv_core opencv_imgproc opencv_imgcodecs opencv_calib3d opencv_features2d opencv_videoio protobuf pthread)

install(TARGETS main DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})